// 加载FORM表单扩展

$(function () {
    layui.use(['form'], function(){
        var form = layui.form()
            ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            new_password: function(value){
                if(+value < 1) {
                    return '请填写新密码';
                }

            }
            ,confirm_password: function(value){
                if(value.length < 1) {
                    return '确认新密码不能为空';
                }

            }
        });

        //监听提交
        form.on('submit(submit)', function(data){
            $.ajax({
                url: "account_manage",
                type: "post",
                data:data.field ,
                dataType: "json",
                success: function (response) {
                    console.log(response);
                    if (response.status == "success") {
                        window.location.href = '/passport/login';
                    } else {
                        layer.msg(response.msg, {icon: 5, shift: 6}, function(){});
                    }
                }
            });
        });

        // 刷新表单
        form.render();

    });
});